home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / ccmd / cmfncs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-03  |  11.0 KB  |  424 lines

  1. /*
  2.  Author: Andrew Lowry
  3.  
  4.  Columbia University Center for Computing Activities, July 1986.
  5.  Copyright (C) 1986, 1987, Trustees of Columbia University in the City
  6.  of New York.  Permission is granted to any individual or institution
  7.  to use, copy, or redistribute this software so long as it is not sold
  8.  for profit, provided this copyright notice is retained.
  9. */
  10. /* Internal symbols, declarations, and storage allocations required by
  11. ** the system modules of the ccmd package.  This file is generated
  12. ** automatically by m4 from information in cmfnc.h4 and the various
  13. ** cm???.cnf configuration files.  The initial portion of this file,
  14. ** including this comment, is copied verbatim from the file cmfnc.top.
  15. */
  16.  
  17. /*
  18. ** The ftspec structure contains information for parsing a particular
  19. ** field type, including pointers to three handler functions, and a pointer
  20. ** to a default break table.  The parsing handler is invoked when an
  21. ** attempt is made to parse the current input using this field type.
  22. ** The help handler is invoked to provide a standard help message for
  23. ** this field.  The completion handler is invoked when the user has
  24. ** requested completion for this field type.  Calling conventions are as
  25. ** follows:
  26. **
  27. ** _ftprs (parse handler):
  28. **   Input arguments:
  29. **      text - A pointer to the text to be parsed.
  30. **      textlen - The number of characters in the text.
  31. **      fdbp - A pointer to the FDB that caused this handler to be invoked.
  32. **
  33. **   Output arguments:
  34. **     parselen - The number of characters consumed by a successful parse.
  35. **     value - A pointer to a data item to be filled with the result of
  36. **       a successful parse.  (The data item is not allocated by the
  37. **       parse handler -- the passed pointer must point to an existing 
  38. **     item.)
  39. **
  40. **   Returns: Standard return code.
  41. **
  42. ** _fthlp (help handler):
  43. **   Input arguments:
  44. **      text - A pointer to the text being parsed.
  45. **      textlen - The number of characters in text.
  46. **      fdbp - A pointer to the FDB that caused this handler to be invoked.
  47. **      cust - TRUE if a custom help string was typed for this FDB
  48. **
  49. **   Output arguments: None.
  50. **
  51. **   Returns: Standard return code.
  52. **
  53. ** _ftcmp (completion handler):
  54. **   Input arguments:
  55. **     text - A pointer to the text being parsed.
  56. **     textlen - The number of characters in text.
  57. **     fdbp - A pointer to the FDB that caused this handler to be invoked.
  58. **     full - TRUE if full completion is requested, otherwise only partial
  59. **       completion is required.
  60. **
  61. **   Output arguments:
  62. **     cplt - A pointer to the completion text to be filled in.  NULL
  63. **       means no completion text.
  64. **     cpltlen - If cplt is not NULL, the number of characters to fill
  65. **       in.  -1 means fill in to the end of the completion string
  66. **       (zero terminated).
  67. **
  68. **   Returns: Flags (defined below) whether or not to:
  69. **     - Beep at the user (flag CMP_BEL)
  70. **     - Add a space after the completion text (flag CMP_SPC)
  71. **     - Stop completion after first punctuation char (flag CMP_PNC)
  72. **     - Wake up the parse (flag CMP_GO)
  73. **/
  74.  
  75. typedef struct FTSPEC {
  76.   int (*_ftprs)();        /* parse handler address */
  77.   int (*_fthlp)();        /* help handler address */
  78.   int (*_ftcmp)();        /* completion handler address */
  79.   int _ftflg;            /* field type flags */
  80.   brktab *_ftbrk;        /* standard break table */
  81. } ftspec;
  82.   
  83. /* Flags defined for ftspec structure (_ftflg field) */
  84.  
  85. #define    FT_DFX    0x0001        /* blocks defaulting on confirm */
  86.  
  87. /* Flags to be returned by completion handlers */
  88.  
  89. #define CMP_BEL    0x0001        /* beep at the user */
  90. #define CMP_SPC    0x0002        /* add space after completion text */
  91. #define CMP_GO    0x0004        /* wakeup requested */
  92. #define CMP_PNC    0x0008        /* end completion after first punctuation */
  93.  
  94. /* global break table shared by some parse functions */
  95.  
  96. extern brktab cmallbk;
  97.  
  98. /* Error table, indexed by the left byte of an error code,
  99. ** points to a function error structure, which includes a count
  100. ** of the number of error codes in the table, and a pointer to
  101. ** an array of error strings, indexed by the right byte of the
  102. ** error code.
  103. **/
  104.  
  105. typedef struct FNERR {
  106.   int _fecnt;            /* number of error strings in table */
  107.   char **_ferrs;        /* pointer to array of error strings */
  108. } fnerr;
  109.  
  110. /* badfnc - Macro to decide whether a given function code is legal.
  111. ** First, the code is checked for a range error.  If it passes, the
  112. ** function table entry is checked for a NULL parse function pointer,
  113. ** indicating that the function has been stubbed out of this application.
  114. **/
  115.  
  116. #define badfnc(code)    (((code) < 1) || ((code) > cmfmax) ? TRUE : \
  117.              (cmfntb[(code)-1]->_ftprs == NULL))
  118.  
  119. /* Some useful character constants */
  120.  
  121. #define NULCHAR    '\0'
  122. #define    BELL    '\007'
  123. #define BS    '\010'
  124. #define    TAB    '\t'        /* ASCII 011 */
  125. #define    NEWLINE    '\n'        /* ASCII 012 */
  126. #define FORMFEED '\014'
  127. #define    RETURN    '\r'        /* ASCII 015 */
  128. #define SPACE    '\040'
  129. #define DELETE    '\177'
  130.  
  131. /*
  132.  * Macros to inspect break tables:
  133.  *  BREAK1(b,c) => nonzero iff character c is a 1st character break in
  134.  *    break table *b.
  135.  *  BREAKR(b,c) => nonzero iff character c is a non-1st character break in
  136.  *    break table *b.
  137.  *  BREAK(b,c,p) => nonzero iff character c is a break character in position
  138.  *    p according to break table *b.  (p should be 0 to check for 1st char
  139.  *    break, nonzero otherwise.)
  140.  */
  141.  
  142. #define    BREAK1(b,c)    (0x80 & ((b)->_br1st[(c)/8] << ((c) % 8)))
  143. #define    BREAKR(b,c)    (0x80 & ((b)->_brrest[(c)/8] << ((c) % 8)))
  144. #define BREAK(b,c,p)    ((p) == 0 ? BREAK1(b,c) : BREAKR(b,c))
  145.  
  146.  
  147. /* Generic ccmd error messages */ 
  148.  
  149. #ifdef GENERR
  150.  
  151. static char *(generr[23]) = {
  152.         "No error",
  153.         "Reparse required",
  154.         "Unable to parse input",
  155.         "Unknown function code in FDB",
  156.         "Command buffer overflow",
  157.         "Atom buffer overflow",
  158.         "End of file encountered on command input",
  159.         "More input required for successful parse",
  160.         "Empty FDB chain presented for parsing",
  161.         "Wakeup requested",
  162.         "Deferred action requested",
  163.         "Automatic reparse mechanism failed or not available",
  164.         "Default string could not be inserted",
  165.         "Internal work buffer overflow",
  166.         "Error in command line I/O operation",
  167.         "Must allocate parse buffers before beginning parse",
  168.         "Must issue prompt before parsing command line",
  169.         "Retry requested by parse routine",
  170.         "Automatic parse error handler failed",
  171.         "Completion routine requested a bell",
  172.         "Completion routine requested a bell and wakeup",
  173.         "Internal Stack Overflow",
  174.         "Internal Stack Underflow"
  175. };
  176. fnerr fe_gen = { 23, generr };
  177. #else
  178. extern fnerr fe_gen;
  179. #endif
  180.  
  181. /* Error table and other configuration data for cmcfm */
  182.  
  183.  
  184. #ifdef CFMERR
  185.  
  186. static char *(cfmerr[1]) = {
  187.         "Not confirmed"
  188. };
  189. fnerr fe_cfm = { 1, cfmerr };
  190. #else
  191. extern fnerr fe_cfm;
  192. #endif
  193.  
  194. /* Error table and other configuration data for cmkey */
  195.  
  196.  
  197. #ifdef KEYERR
  198.  
  199. static char *(keyerr[3]) = {
  200.         "Does not match keyword",
  201.         "Ambiguous",
  202.         "Invalid abbreviation chain in keyword table"
  203. };
  204. fnerr fe_key = { 3, keyerr };
  205. #else
  206. extern fnerr fe_key;
  207. #endif
  208.  
  209. /* Error table and other configuration data for cmnum */
  210.  
  211.  
  212. #ifdef NUMERR
  213.  
  214. static char *(numerr[4]) = {
  215.         "Radix must be from 2 to 16",
  216.         "Number must be unsigned",
  217.         "Not a valid number in specified radix",
  218.         "Number too large for this machine"
  219. };
  220. fnerr fe_num = { 4, numerr };
  221. #else
  222. extern fnerr fe_num;
  223. #endif
  224.  
  225. /* Error table and other configuration data for cmqst */
  226.  
  227.  
  228. #ifdef QSTERR
  229.  
  230. static char *(qsterr[3]) = {
  231.         "First character is not a valid delimiter",
  232.         "Invalid character inside delimited string",
  233.         "Not a proper delimiter"
  234. };
  235. fnerr fe_qst = { 3, qsterr };
  236. #else
  237. extern fnerr fe_qst;
  238. #endif
  239.  
  240. /* Error table and other configuration data for cmnoi */
  241.  
  242.  
  243. #ifdef NOIERR
  244.  
  245. static char *(noierr[1]) = {
  246.         "Invalid noise word"
  247. };
  248. fnerr fe_noi = { 1, noierr };
  249. #else
  250. extern fnerr fe_noi;
  251. #endif
  252.  
  253. /* Error table and other configuration data for cmtxt */
  254.  
  255.  
  256. #ifdef TXTERR
  257.  
  258. static char *(txterr[1]) = {
  259.         "Illegal characters in line of text"
  260. };
  261. fnerr fe_txt = { 1, txterr };
  262. #else
  263. extern fnerr fe_txt;
  264. #endif
  265.  
  266. /* Error table and other configuration data for cmfld */
  267.  
  268.  
  269. #ifdef FLDERR
  270.  
  271. static char *(flderr[1]) = {
  272.         "Does not match Field"
  273. };
  274. fnerr fe_fld = { 1, flderr };
  275. #else
  276. extern fnerr fe_fld;
  277. #endif
  278.  
  279. /* Error table and other configuration data for cmswi */
  280.  
  281.  
  282. #ifdef SWIERR
  283.  
  284. static char *(swierr[5]) = {
  285.         "Does not match switch",
  286.         "Ambiguous",
  287.         "Invalid abbreviation chain in switch table",
  288.         "Switch does not begin with required punctuation",
  289.         "Final switch punctuation not allowed on selected switch"
  290. };
  291. fnerr fe_swi = { 5, swierr };
  292. #else
  293. extern fnerr fe_swi;
  294. #endif
  295.  
  296. /* Error table and other configuration data for cmtok */
  297.  
  298.  
  299. #ifdef TOKERR
  300.  
  301. static char *(tokerr[1]) = {
  302.         "Does not match token string"
  303. };
  304. fnerr fe_tok = { 1, tokerr };
  305. #else
  306. extern fnerr fe_tok;
  307. #endif
  308.  
  309. /* Error table and other configuration data for cmtad */
  310.  
  311.  
  312. #ifdef TADERR
  313.  
  314. static char *(taderr[4]) = {
  315.         "Both time and date are suppressed in time/date parse",
  316.         "Invalid time",
  317.         "Invalid date",
  318.         "Invalid time and date"
  319. };
  320. fnerr fe_tad = { 4, taderr };
  321. #else
  322. extern fnerr fe_tad;
  323. #endif
  324.  
  325. /* Error table and other configuration data for cmfil */
  326.  
  327.  
  328. #ifdef FILERR
  329.  
  330. static char *(filerr[6]) = {
  331.         "Does not match filename",
  332.         "Ambiguous",
  333.         "Cannot specify wildcards in nonwild parse",
  334.         "Invalid combination of parse flags",
  335.         "Invalid file spec",
  336.         "Ambiguous"
  337. };
  338. fnerr fe_fil = { 6, filerr };
  339. #else
  340. extern fnerr fe_fil;
  341. #endif
  342.  
  343. /* Error table and other configuration data for cmusr */
  344.  
  345.  
  346. #ifdef USRERR
  347.  
  348. static char *(usrerr[2]) = {
  349.         "Does not match username",
  350.         "Ambiguous"
  351. };
  352. fnerr fe_usr = { 2, usrerr };
  353. #else
  354. extern fnerr fe_usr;
  355. #endif
  356.  
  357. /* Error table and other configuration data for cmgrp */
  358.  
  359.  
  360. #ifdef GRPERR
  361.  
  362. static char *(grperr[2]) = {
  363.         "Does not match group name",
  364.         "ambiguous"
  365. };
  366. fnerr fe_grp = { 2, grperr };
  367. #else
  368. extern fnerr fe_grp;
  369. #endif
  370.  
  371. /* Error table and other configuration data for cmpara */
  372.  
  373.  
  374. #ifdef PARAERR
  375.  
  376. static char *(paraerr[1]) = {
  377.         "Out of memory"
  378. };
  379. fnerr fe_para = { 1, paraerr };
  380. #else
  381. extern fnerr fe_para;
  382. #endif
  383.  
  384. /* Error table and other configuration data for cmchar */
  385.  
  386.  
  387. #ifdef CHARERR
  388.  
  389. fnerr fe_char = { 0, NULL };
  390. #else
  391. extern fnerr fe_char;
  392. #endif
  393.  
  394. #ifdef STORAGE
  395.  
  396. /* Function handler table */
  397.  
  398. extern ftspec
  399.   ft_cfm, ft_key, ft_num, ft_qst, ft_noi, ft_txt, ft_fld, ft_swi, ft_tok, 
  400.   ft_tad, ft_fil, ft_usr, ft_grp, ft_para, ft_char ;
  401.  
  402. ftspec *(cmfntb[15]) = {
  403.   &ft_cfm, &ft_key, &ft_num, &ft_qst, &ft_noi, &ft_txt, &ft_fld, &ft_swi, 
  404.   &ft_tok, &ft_tad, &ft_fil, &ft_usr, &ft_grp, &ft_para, &ft_char 
  405. };
  406.  
  407. /* Error table table */
  408.  
  409. fnerr *(fnetab[16]) = {
  410.   &fe_gen, &fe_cfm, &fe_key, &fe_num, &fe_qst, &fe_noi, &fe_txt, &fe_fld, 
  411.   &fe_swi, &fe_tok, &fe_tad, &fe_fil, &fe_usr, &fe_grp, &fe_para, &fe_char 
  412.   
  413. };
  414.  
  415. /* Number of defined functions */
  416.  
  417. int cmfmax = 16;
  418.  
  419. #else
  420. extern ftspec *(cmfntb[]);
  421. extern fnerr *(fnetab[]);
  422. extern int cmfmax;
  423. #endif
  424.